<?php

namespace App\Repositories;

/**
 * Interface RepositoryContract
 * @package App\Repositories
 * Date: 21/03/2018
 * @author George
 */
interface RepositoryContract
{
	/**
	 * 获取所有资源集合
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param array $columns
	 * @return \Illuminate\Database\Eloquent\Collection|static[]
	 */
	public function all(array $columns = ['*']);

	/**
	 * 获取资源汇总
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @return int
	 */
	public function count();

	/**
	 * 创建资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param array $data
	 * @return mixed
	 */
	public function create(array $data);

	/**
	 * 创建多个资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param array $data
	 * @return mixed
	 */
	public function createMultiple(array $data);

	/**
	 * 销毁指定的模型资源
	 *
	 * Date: 22/03/2018
	 * @author George
	 * @param Model $model
	 * @param bool $force
	 * @return bool|null
	 * @throws GeneralException
	 */
	public function destroy($model, $force = false);

	/**
	 * 根据查询条件批量删除资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @return mixed
	 */
	public function delete();

	/**
	 * 根据主键删除资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $primary
	 * @return mixed
	 */
	public function deleteByPrimary($primary);

	/**
	 * 根据多个主键删除对应资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param array $ids
	 * @return mixed
	 */
	public function deleteMultipleByPrimary(array $ids);

	/**
	 * 获取第一个资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param array $columns
	 * @return mixed
	 */
	public function first(array $columns = ['*']);

	/**
	 * 获取资源集合
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param array $columns
	 * @return mixed
	 */
	public function get(array $columns = ['*']);

	/**
	 * 根据主键获取资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $primary
	 * @param array $columns
	 * @return mixed
	 */
	public function getByPrimary($primary, array $columns = ['*']);

	/**
	 * 获取指定列
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $item
	 * @param $column
	 * @param array $columns
	 * @return mixed
	 */
	public function getByColumn($item, $column, array $columns = ['*']);

	/**
	 * 设置分页
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param int $limit
	 * @param array $columns
	 * @param string $pageName
	 * @param null $page
	 * @return mixed
	 */
	public function paginate($limit = 25, array $columns = ['*'], $pageName = 'page', $page = null);

	/**
	 * 根据主键更新资源
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $primary
	 * @param array $data
	 * @param array $options
	 * @return mixed
	 */
	public function updateByPrimary($primary, array $data, array $options = []);

	/**
	 * 设置查询条数
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $limit
	 * @return mixed
	 */
	public function limit($limit);

	/**
	 * 设置查询排序
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $column
	 * @param $value
	 * @return mixed
	 */
	public function orderBy($column, $value);

	/**
	 * 设置查询条件
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $column
	 * @param $value
	 * @param string $operator
	 * @return mixed
	 */
	public function where($column, $value, $operator = '=');

	/**
	 * 设置WhereIn查询条件
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $column
	 * @param $value
	 * @return mixed
	 */
	public function whereIn($column, $value);

	/**
	 * 设置关联关系懒加载
	 *
	 * Date: 21/03/2018
	 * @author George
	 * @param $relations
	 * @return mixed
	 */
	public function with($relations);
}
